﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Runtime.Serialization;
using System.Collections.ObjectModel;

namespace SmartMD.DataAccess.Service
{
    /// <summary>
    /// 分页查询结果类
    /// </summary>
    /// <typeparam name="T"></typeparam>
    [DataContract(Name = "Page", Namespace = "")]
    public class PagingQueryResult<T>
    {
        /// <summary>
        /// 分页大小
        /// </summary>
        [DataMember(Name = "pageSize")]
        public int PageSize { get; set; }

        /// <summary>
        /// 总行数
        /// </summary>
        [DataMember(Name = "totalCount")]
        public int TotalRowCount { get; set; }

        /// <summary>
        /// 当前页索引
        /// </summary>
        [DataMember(Name = "pageNo")]
        public int CurrentPageIndex { get; set; }

        /// <summary>
        /// 总页数
        /// </summary>
        [DataMember(Name = "totalPages")]
        public int TotalPageCount { get; set; }

        /// <summary>
        /// 查询结果
        /// </summary>
        [DataMember(Name = "result")]
        public ObservableCollection<T> Result { get; set; }
    }

    /// <summary>
    /// 如果服务端返回一个字符串列表，需要使用该类作为返回结果类型，而不能使用泛型string List类型
    /// </summary>
    [CollectionDataContract(Namespace = "")]
    public class DataContractStringCollection : List<string> { }

    /// <summary>
    /// 如果服务端返回一个字典，需要使用该类型作为返回结果类型，而不能直接使用泛型字典
    /// 对应服务端map对象
    /// </summary>
    /// <typeparam name="TKey"></typeparam>
    /// <typeparam name="TValue"></typeparam>
    [CollectionDataContract(Name = "map", Namespace = "", ItemName = "entry", KeyName = "key", ValueName = "value")]
    public class DataContractDictionary<TKey, TValue> : Dictionary<TKey, TValue> { }
}
